package com.xiaoma.tpo.dao;

import java.util.List;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Repository;

import com.xiaoma.tpo.baseDao.BaseDaoImpl;
import com.xiaoma.tpo.baseDao.DefaultRowMapper;
import com.xiaoma.tpo.domain.MkReading;
import com.xiaoma.tpo.dto.MkReadingParagraphVo;

@Repository
public class MkReadingDao extends BaseDaoImpl<MkReading>{
    
    private static final Logger LOG = LoggerFactory.getLogger(MkReadingDao.class);
    
    @SuppressWarnings("unchecked")
    public List<MkReadingParagraphVo> findByTpoId(int tpoId) {
        String sql = "SELECT a.*,b.seq_num, b.content, b.content_cn FROM mk_reading a left join mk_reading_paragraph b on a.id = b.mk_reading_id where a.mk_tpo_id = ?";
        LOG.info("SQL:{} PARAMS:{}", sql, tpoId);
        List<?> result = jdbcTemplate.query(sql, new DefaultRowMapper(MkReadingParagraphVo.class, getNameHandler()), tpoId);
        return (List<MkReadingParagraphVo>)result;
    }

}
